package ListQueue;

public class DLLNode<E> {

    protected E element;
    protected DLLNode<E> nextElement;
    protected DLLNode<E> previousElement;

    public DLLNode() {

    }

    public DLLNode(E data) {

        element = data;
    }

    public DLLNode(E data, DLLNode<E> next, DLLNode<E> previous) {
        element = data;
        nextElement = next;
        if (nextElement != null)
            nextElement.previousElement = this;
        previousElement = previous;
        if (previousElement != null)
            previousElement.nextElement = this;
    }

    public DLLNode<E> next() {
        return nextElement;
    }

    public DLLNode<E> previous() {
        return previousElement;
    }

    public E value() {
        return element;
    }

    public void setNext(DLLNode<E> next) {
        nextElement = next;
    }

    public void setPrevious(DLLNode<E> previous) {
        previousElement = previous;
    }

    public void setValue(E value) {
        element = value;
    }

    @Override
    public String toString() {

        return element.toString();
    }

}